|
File attached compile time script does most of its work
by handling events fired by the compiler. While embedded scripts
run once during a strictly defined phase of the file processing, file
attached scripts live time corresponds to the entire file
processing. Thus they are able to perform more complex tasks and
are able to interact with the compiler at every important phase of
the file processing. Furthermore they are able even to command the
compiler to skip a particular file or to process it several times
with different options.
Typical usage of file embedded script involve handling of only
two (or one of them) of the events listed below - OnProcessFile
and OnCheckStructure. However file attached script is able
to perform more complex and specific tasks by handling some of the
other events. Reading their documentation could be skipped without
risk and you could return here when you fill you need some
functionality not available through the two major events.
Events are handled by writing a routine in the CTS with
the name and parameters of the event. Every event description
contains a function/sub prototype and little example. If the
function/sub is not defined compiler assumes the event is not
handled. Thus you need to include code only for the handled
events.
Events:
Most frequently used:
OnProcessFile -
Informs the script for the processed file. By processing the
event script is able to change the output file name, cause
multiply processing of the same file to be done, change some
parameters or skip/end file processing.
OnCheckStructure
- Informs the script the file is parsed and gives it access to
the logical representation of the file - the Page Object Model
(document tree of the parsed file). Most of the work the script
needs to do is performed here. The script is able to modify the
tree of the document in almost unlimited ways. This could be a
template oriented usage of the input file for multiply file
generation or could be code injection in some script determined
places of the file.
Advanced events
OnModifyParser
- By default Page Object Model served to the script through the
OnCheckStructure event is the model corresponding to the file processing
option - includes ASP tags, SCRIPT RUNAT=COMPILER and CUSTOM
tags for ASPToASP, ASPToVB processing and contains only SCRIPT
and CUSTOM tags in case of SSIToHTML processing. If the script
needs to access other parts of the page (usually typical HTML
elements - such as TITLE or META tags) the script is able to
request these elements to be included in the document tree when
parsing the document. By simple call to the AddTag method of the
parser the object model served later in the OnCheckStructure
event is extended..
OnRequireCompletion
- This event is fired at the very end of the file processing. It
is fired only once! E.g. if the script causes the compiler to
process the file multiply times (see OnProcessFile) this event
will be fired after the last file processing operation. Through
this event the script is asked to register a completion
procedure (script). Completion procedure is something that could
be done only after processing all the files in the project. For
example generating files from information collected from the
processed files.
Special events. Supplied to give the script
chance to solve non-standard problems and perform some very
specific tasks that do not fit in the ASP Compiler's
architecture.
OnCreateOutput
-
OnOutputCreated
-
OnLoaderFileCreated
-
Events firing order.- see the First phase of the build and CTS
|